/*
 * @Descripttion: 
 * @version: 
 * @Author: Shuai XUE
 * @Date: 2021-02-24 21:05:04
 * @LastEditors: Shuai XUE
 * @LastEditTime: 2021-02-24 21:37:00
 */
/**
 * @Author: zc
 * @Date: 2020-04-08 09:48:27
 * @LastEditors: zc
 * @LastEditTime: 2020-07-14 16:18:01
*/
const path = require('path')
const sshNginx = require('node-ssh-modify-nginx')

const { npm_package_name, npm_lifecycle_script } = process.env
const REACT_APP_BUILD = npm_lifecycle_script.split(' ')[1].split('=')[1]
const _url = `/${npm_package_name}/${REACT_APP_BUILD}`
const _value = `
    location ${_url} {
        alias /home/react${_url}/;
        try_files $uri $uri/ ${_url}/index.html;
        index index.html;
        gzip on;
    }
  `
new sshNginx({
  host: '11.50.49.179',
  password: 'Zl^Xt1Qb*D2020@yeah',
  extendNgConf: _value,
  extendNgLinenum: 72,
  local: path.resolve(__dirname, `${npm_package_name}-xpc-nginx.conf`),
  ergStr: `location ${_url} {`,
  serverPath: '/etc/nginx/conf.d'
}).init()